package com.gzhryc.shared_device.oem.code.member.dao;

import com.gzhryc.jdbc.Conditions;
import com.gzhryc.jdbc.NumberBranchTableDao;
import com.gzhryc.jdbc.Query;
import com.gzhryc.shared_device.oem.code.member.dao.db.MemberWallet;

import java.sql.SQLException;

public class MemberWalletDao extends NumberBranchTableDao<MemberWallet> {

	public MemberWalletDao(String jdbcKey) {
		super(jdbcKey);
	}

	public MemberWalletDao(String jdbcKey,Long id) {
		super(jdbcKey,id);
	}

	public Long sumMoneyByConditions(Conditions conditions) throws SQLException {
		String sql = "SELECT SUM(money) FROM " + this.tableName;
		Query query = new Query(sql);
		query.appendSql(conditions.toSql(query.getParams(),true));
		return jdbcHelper.getFirstField(query,Long.class);
	}
}
